<template>
  <div class="blind--review">
    <div class="blind--wrap" v-if="pos == '甲状腺'">
      <div class="blind--sub">甲状腺:</div>
      <div class="blind--item">
        <span class="blind--name">峡部横切面:</span>
        <a-radio-group v-model="crossThmus">
          <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
          <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
        </a-radio-group>
      </div>
      <div class="blind--item">
        <span class="blind--name">左侧叶横切面:</span>
        <a-radio-group v-model="crossLeftLobe">
          <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
          <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
        </a-radio-group>
      </div>
      <div class="blind--item">
        <span class="blind--name">左侧叶纵切面:</span>
        <a-radio-group v-model="LongLeftLobe">
          <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
          <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
        </a-radio-group>
      </div>
      <div class="blind--item">
        <span class="blind--name">右侧叶横切面:</span>
        <a-radio-group v-model="crossRightLobe">
          <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
          <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
        </a-radio-group>
      </div>
      <div class="blind--item">
        <span class="blind--name">右侧叶纵切面:</span>
        <a-radio-group v-model="LongRIghtLobe">
          <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
          <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
        </a-radio-group>
      </div>
    </div>
    <div class="blind--wrap" v-if="pos == '颈动脉'">
      <div class="blind--sub">颈动脉:</div>
      <div class="blind--item">
        <span class="blind--name artery">左侧颈总动脉横切面:</span>
        <a-radio-group v-model="LeftCrossCCA">
          <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
          <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
        </a-radio-group>
      </div>
      <div class="blind--item">
        <span class="blind--name artery">左侧窦部横切面:</span>
        <a-radio-group v-model="LeftCrossBifurcation">
          <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
          <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
        </a-radio-group>
      </div>
      <div class="blind--item">
        <span class="blind--name artery">左侧颈内及颈外动脉横切面:</span>
        <a-radio-group v-model="LeftCrossICAECA">
          <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
          <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
        </a-radio-group>
      </div>
      <div class="blind--item">
        <span class="blind--name artery">左侧颈内及颈外动脉纵切面:</span>
        <a-radio-group v-model="LeftLongCCA">
          <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
          <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
        </a-radio-group>
      </div>
      <div class="blind--item">
        <span class="blind--name artery">左侧颈总动脉纵切面:</span>
        <a-radio-group v-model="LeftLongICA">
          <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
          <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
        </a-radio-group>
      </div>
      <div class="blind--item">
        <span class="blind--name artery">左侧颈总动脉起始部纵切面:</span>
        <a-radio-group v-model="LeftLongCCAStartSeg">
          <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
          <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
        </a-radio-group>
      </div>
      <div class="blind--item">
        <span class="blind--name artery">右侧颈总动脉横切面:</span>
        <a-radio-group v-model="rightCrossCCA">
          <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
          <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
        </a-radio-group>
      </div>
      <div class="blind--item">
        <span class="blind--name artery">右侧窦部横切面:</span>
        <a-radio-group v-model="rightCrossBifurcation">
          <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
          <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
        </a-radio-group>
      </div>
      <div class="blind--item">
        <span class="blind--name artery">右侧颈内及颈外动脉横切面:</span>
        <a-radio-group v-model="rightCrossICAECA">
          <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
          <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
        </a-radio-group>
      </div>
      <div class="blind--item">
        <span class="blind--name artery">右侧颈内及颈外动脉纵切面:</span>
        <a-radio-group v-model="rightLongCCA">
          <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
          <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
        </a-radio-group>
      </div>
      <div class="blind--item">
        <span class="blind--name artery">右侧颈总动脉纵切面:</span>
        <a-radio-group v-model="rightLongICA">
          <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
          <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
        </a-radio-group>
      </div>
      <div class="blind--item">
        <span class="blind--name artery">右侧颈总动脉起始部纵切面:</span>
        <a-radio-group v-model="rightLongCCAStartSeg">
          <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
          <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
        </a-radio-group>
      </div>
    </div>
    <div class="blind--wrap" v-if="pos == '腹部'">
      <template v-if="type == 'liver'">
        <div class="blind--sub">一.肝脏:</div>
        <div class="blind--item">
          <span class="blind--name artery">肝左叶经腹主动脉长轴纵切面:</span>
          <a-radio-group v-model="liver1">
            <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
            <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
          </a-radio-group>
        </div>
        <div class="blind--item">
          <span class="blind--name artery">肝左叶斜切面:</span>
          <a-radio-group v-model="liver2">
            <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
            <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
          </a-radio-group>
        </div>
        <div class="blind--item">
          <span class="blind--name artery">肋下斜切第二肝门切面:</span>
          <a-radio-group v-model="liver3">
            <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
            <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
          </a-radio-group>
        </div>
        <div class="blind--item">
          <span class="blind--name artery">右肋下右肝及右肾纵切面:</span>
          <a-radio-group v-model="liver4">
            <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
            <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
          </a-radio-group>
        </div>
        <div class="blind--item">
          <span class="blind--name artery">右肋间经第一肝门斜切面:</span>
          <a-radio-group v-model="liver5">
            <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
            <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
          </a-radio-group>
        </div>
        <div class="blind--sub">二.胆囊:</div>
        <div class="blind--item">
          <span class="blind--name">胆囊长轴纵切面:</span>
          <a-radio-group v-model="gallbladder1">
            <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
            <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
          </a-radio-group>
        </div>
        <div class="blind--sub">三.胰腺:</div>
        <div class="blind--item">
          <span class="blind--name">胰腺长轴切面:</span>
          <a-radio-group v-model="pancreas1">
            <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
            <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
          </a-radio-group>
        </div>
      </template>
      <template v-if="type == 'spleen'">
        <div class="blind--sub">脾脏:</div>
        <div class="blind--item">
          <span class="blind--name">脾脏纵切面:</span>
          <a-radio-group v-model="spleen1">
            <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
            <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
          </a-radio-group>
        </div>
      </template>
    </div>
    <div class="blind--wrap" v-if="pos == '肾脏' || pos == '泌尿'">
      <div class="blind--sub">肾脏:</div>
      <div class="blind--item">
        <span class="blind--name artery">左肾脏的长轴切面:</span>
        <a-radio-group v-model="kidney1">
          <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
          <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
        </a-radio-group>
      </div>
      <div class="blind--item">
        <span class="blind--name artery">右肾脏的长轴切面:</span>
        <a-radio-group v-model="kidney2">
          <a-radio value="合格" :style="radioStyle"> 合格 </a-radio>
          <a-radio value="不合格" :style="radioStyle"> 不合格 </a-radio>
        </a-radio-group>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Recognition",
  props: ["pos","type","small"],
  data() {
    return {
      crossThmus: "", //峡部横切面
      crossLeftLobe: "", //左侧叶横切面
      LongLeftLobe: "", //左侧叶纵切面
      crossRightLobe: "", //右侧叶横切面
      LongRIghtLobe: "", //右侧叶纵切面

      LeftCrossCCA: "", //左侧颈总动脉横切面
      LeftCrossBifurcation: "", //左侧窦部横切面
      LeftCrossICAECA: "", //左侧颈内及颈外动脉横切面
      LeftLongCCA: "", //左侧颈内及颈外动脉纵切面
      LeftLongICA: "", //左侧颈总动脉纵切面
      LeftLongCCAStartSeg: "", //左侧颈总动脉起始部纵切面
      rightCrossCCA: "", //右侧颈总动脉横切面
      rightCrossBifurcation: "", //右侧窦部横切面
      rightCrossICAECA: "", //右侧颈内及颈外动脉横切面
      rightLongCCA: "", //右侧颈内及颈外动脉纵切面
      rightLongICA: "", //右侧颈总动脉纵切面
      rightLongCCAStartSeg: "", //右侧颈总动脉起始部纵切面

      liver1: "", //肝左叶经腹主动脉长轴纵切面
      liver2: "", //肝左叶斜切面
      liver3: "", //肋下斜切第二肝门切面
      liver4: "", //右肋下右肝及右肾纵切面
      liver5: "", //右肋间经第一肝门斜切面
      gallbladder1: "", //胆囊长轴纵切面
      pancreas1: "", //胰腺长轴切面
      spleen1: "", //脾脏纵切面

      kidney1: "", //左肾脏的长轴切面
      kidney2: "", //右肾脏的长轴切面
    };
  },
  computed:{
    radioStyle(){
      if(this.small){
        return {display: 'block'}
      }else{
        return {}
      }
    }
  },
  created() {
    this.$EventBus.$on("rec_initOldResult", this.initOldResult);
  },
  methods: {
    initOldResult(val) {
      console.log("initOldResult val",val)
      try {
        if (this.pos == "甲状腺") {
          const map = {
            峡部横切面: "crossThmus",
            左侧叶横切面: "crossLeftLobe",
            左侧叶纵切面: "LongLeftLobe",
            右侧叶横切面: "crossRightLobe",
            右侧叶纵切面: "LongRIghtLobe",
          };
          for (const prop in val) {
            if (map[prop]) {
              this[map[prop]] = val[prop];
            }
          }
        } else if (this.pos == "颈动脉") {
          const map = {
            左侧颈总动脉横切面: "LeftCrossCCA",
            左侧窦部横切面: "LeftCrossBifurcation",
            左侧颈内及颈外动脉横切面: "LeftCrossICAECA",
            左侧颈内及颈外动脉纵切面: "LeftLongCCA",
            左侧颈总动脉纵切面: "LeftLongICA",
            左侧颈总动脉起始部纵切面: "LeftLongCCAStartSeg",
            右侧颈总动脉横切面: "rightCrossCCA",
            右侧窦部横切面: "rightCrossBifurcation",
            右侧颈内及颈外动脉横切面: "rightCrossICAECA",
            右侧颈内及颈外动脉纵切面: "rightLongCCA",
            右侧颈总动脉纵切面: "rightLongICA",
            右侧颈总动脉起始部纵切面: "rightLongCCAStartSeg",
          };
          for (const prop in val) {
            if (map[prop]) {
              this[map[prop]] = val[prop];
            }
          }
        } else if (this.pos == "腹部") {
          for (const prop in val) {
            if (prop == "肝脏") {
              const targetVal = val[prop];
              const map = {
                肝左叶经腹主动脉长轴纵切面: "liver1",
                肝左叶斜切面: "liver2",
                肋下斜切第二肝门切面: "liver3",
                右肋下右肝及右肾纵切面: "liver4",
                右肋间经第一肝门斜切面: "liver5",
              };
              for (const p in targetVal) {
                if (map[p]) {
                  this[map[p]] = targetVal[p];
                }
              }
            } else if (prop == "胆囊") {
              const targetVal = val[prop];
              const map = {
                胆囊长轴纵切面: "gallbladder1",
              };
              for (const p in targetVal) {
                if (map[p]) {
                  this[map[p]] = targetVal[p];
                }
              }
            } else if (prop == "胰腺") {
              const targetVal = val[prop];
              const map = {
                胰腺长轴切面: "pancreas1",
              };
              for (const p in targetVal) {
                if (map[p]) {
                  this[map[p]] = targetVal[p];
                }
              }
            } else if (prop == "脾脏") {
              const targetVal = val[prop];
              const map = {
                脾脏纵切面: "spleen1",
              };
              for (const p in targetVal) {
                if (map[p]) {
                  this[map[p]] = targetVal[p];
                }
              }
            }
          }
        } else if (this.pos == "肾脏" || this.pos == "泌尿") {
          const map = {
            左肾脏的长轴切面: "kidney1",
            右肾脏的长轴切面: "kidney2",
          };
          for (const prop in val) {
            if (map[prop]) {
              this[map[prop]] = val[prop];
            }
          }
        }
      } catch (error) {
        console.log("扫查影像合格率 initOldResult error: ", error);
      }
    },
    getResult() {
      try {
        if (this.pos == "甲状腺") {
          if (!this.crossThmus
              || !this.crossLeftLobe
              || !this.LongLeftLobe
              || !this.crossRightLobe
              || !this.LongRIghtLobe
          ) {
            this.$message.warning("请对标准切面识别率进行完整评价!");
            return;
          }
          return {
            甲状腺: {
              峡部横切面: this.crossThmus,
              左侧叶横切面: this.crossLeftLobe,
              左侧叶纵切面: this.LongLeftLobe,
              右侧叶横切面: this.crossRightLobe,
              右侧叶纵切面: this.LongRIghtLobe,
            },
          };
        } else if (this.pos == "颈动脉") {
          if (!this.LeftCrossCCA
              || !this.LeftCrossBifurcation
              || !this.LeftCrossICAECA
              || !this.LeftLongCCA
              || !this.LeftLongICA
              || !this.LeftLongCCAStartSeg
              || !this.rightCrossCCA
              || !this.rightCrossBifurcation
              || !this.rightCrossICAECA
              || !this.rightLongCCA
              || !this.rightLongICA
              || !this.rightLongCCAStartSeg
          ) {
            this.$message.warning("请对标准切面识别率进行完整评价!");
            return;
          }
          return {
            颈动脉: {
              左侧颈总动脉横切面: this.LeftCrossCCA,
              左侧窦部横切面: this.LeftCrossBifurcation,
              左侧颈内及颈外动脉横切面: this.LeftCrossICAECA,
              左侧颈内及颈外动脉纵切面: this.LeftLongCCA,
              左侧颈总动脉纵切面: this.LeftLongICA,
              左侧颈总动脉起始部纵切面: this.LeftLongCCAStartSeg,
              右侧颈总动脉横切面: this.rightCrossCCA,
              右侧窦部横切面: this.rightCrossBifurcation,
              右侧颈内及颈外动脉横切面: this.rightCrossICAECA,
              右侧颈内及颈外动脉纵切面: this.rightLongCCA,
              右侧颈总动脉纵切面: this.rightLongICA,
              右侧颈总动脉起始部纵切面: this.rightLongCCAStartSeg,
            },
          };
        } else if (this.pos == "腹部") {
          if(this.type == "liver"){
            if (!this.liver1
                || !this.liver2
                || !this.liver3
                || !this.liver4
                || !this.liver5
                || !this.gallbladder1
                || !this.pancreas1
            ) {
              this.$message.warning("请对标准切面识别率进行完整评价!");
              return;
            }
          }else{
            if (!this.spleen1) {
              this.$message.warning("请对标准切面识别率进行完整评价!");
              return;
            }
          }
          return {
            肝脏: {
              肝左叶经腹主动脉长轴纵切面: this.liver1,
              肝左叶斜切面: this.liver2,
              肋下斜切第二肝门切面: this.liver3,
              右肋下右肝及右肾纵切面: this.liver4,
              右肋间经第一肝门斜切面: this.liver5,
            },
            胆囊: {
              胆囊长轴纵切面: this.gallbladder1,
            },
            胰腺: {
              胰腺长轴切面: this.pancreas1,
            },
            脾脏: {
              脾脏纵切面: this.spleen1,
            },
          };
        } else if (this.pos == "肾脏" || this.pos == "泌尿") {
          if (!this.kidney1
              || !this.kidney2
          ) {
            this.$message.warning("请对标准切面识别率进行完整评价!");
            return;
          }
          return {
            泌尿: {
              左肾脏的长轴切面: this.kidney1,
              右肾脏的长轴切面: this.kidney2,
            },
          };
        }
      } catch (error) {
        console.log("扫查影像合格率 getResult error: ", error);
      }
    },
  },
  beforeDestroy() {
    this.$EventBus.$off("rec_initOldResult");
  }
};
</script>

<style scoped lang="less">
@import "~@/assets/css/blindReview.less";
</style>
